//  用户模块api
import request from '@/utils/request.js'

/**
 * 登陆请求   参数描述
 * @param {object} data = {mobile: '' code: ''}
 * 使用步骤 1.向外暴露login函数 2.login 返回一个request(相当于return一个promise)
 */
export const login = data => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data
  })
}

/**
 *   发送验证码
 *   一分钟只能发生一条
 * @param {number} mobile
 */
export const sendCode = mobile => {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`
  })
}

export const getMyProfile = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}

export const getUserChannels = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}
